package com.example.second_home_work

import android.annotation.SuppressLint
import android.os.Bundle
import android.util.Log
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import com.example.second_home_work.R.*

class MainActivity : AppCompatActivity() {
    @SuppressLint("MissingInflatedId", "StringFormatMatches")
    override fun onCreate(savedInstanceState: Bundle?) {
        var cnt = 0
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        val button = findViewById<android.widget.Button>(R.id.button)
        val linearLayout = findViewById<android.widget.LinearLayout>(R.id.linearLayout1)
        button.setOnClickListener {
            cnt++
            val textView = android.widget.TextView(this).apply {
                text = context.getString(R.string.scroll_content, cnt)
                textSize = 24f
            }
            linearLayout.addView(textView)
        }

        val button1: android.widget.Button = findViewById(id.button1)
        val spinner: android.widget.Spinner = findViewById(id.spinner)
        val textView: android.widget.TextView = findViewById(id.textView)
        button1.setOnClickListener {
            val text = spinner.selectedItem.toString()
            textView.text = text
        }
    }
}